#include"./DllLoader.hpp"


namespace MMF 
{

    Handle DllLoader::LoadDLL(const std::string& pathName)
    {
        std::string pathWithExt = pathName;
    #ifdef WIN32
        pathWithExt += ".dll";
        ::HMODULE handle = ::LoadLibraryA(pathWithExt.c_str());
        return Handle(handle);
    #else
        pathWithExt += ".so";
        Handle handle = dlopen(pathWithExt.c_str(), RTLD_NOW);
        return Handle(handle);
    #endif
    }

    void DllLoader::CloseDLL(Handle hdl)
    {
    #ifdef WIN32
        FreeLibrary(::HMODULE(hdl));
    #else
        dlclose(hdl);
    #endif
    }
}